<?php

namespace App\Http\Controllers;

use App\Notifications\RegisterMailNotify;
use App\User;
use Illuminate\Http\Request;

class MailController extends Controller
{
    //发送短信的提示页面
    public function sendRegistarMailShow()
    {
        return view('email.sendRegistarMailShow');
    }

    public function sendRegistarMail()
    {
        $user = auth()->user();
        $user->notify(new RegisterMailNotify($user));
        return back()->with('success', '邮件已发送，请进入邮箱进行验证');
    }

    public function sendRegistarSubmit($token)
    {
        $user = User::query()->where('email_token', $token)->first();
        $user->email_status = true;
        $user->save();
        return redirect('/')->with('success', '邮箱验证完成');
    }
}
